<template>
<div class="flex">

  <h3>欢迎来到合同查询</h3>
    <el-form :inline="true" :model="queryForm" class="demo-form-inline">

      <el-form-item label="收房合同编号">
        <el-input v-model="queryForm.sfContractNo" placeholder="收房合同编号"></el-input>
      </el-form-item>

      <el-form-item label="业主姓名">
        <el-input v-model="queryForm.ownerName" placeholder="业主姓名"></el-input>
      </el-form-item><br>

      <el-form-item label="小区名称">
        <el-input v-model="queryForm.premiseName" placeholder="小区名称"></el-input>
      </el-form-item>

      <el-form-item label="合同录入时间">

        <el-date-picker
          v-model="value2"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>

      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="list">查询</el-button>
        <el-button type="primary" @click="reset">重置</el-button>
      </el-form-item>
    </el-form>
  <el-table
    :data="tableData"
    border
    style="width: 100%">
    <el-table-column
      fixed
      prop="sfContractNo"
      label="合同编号"
      width="210">
    </el-table-column>
    <el-table-column
      prop="premiseName"
      label="小区"
      width="120">
    </el-table-column>
    <el-table-column
      prop="signUserMobile"
      label="电话"
      width="120">
    </el-table-column>
    <el-table-column
      prop="leaseStartTime"
      label="起租日期"
      width="120">
    </el-table-column>
    <el-table-column
      prop="leaseEndTime"
      label="结束日期"
      width="120">
    </el-table-column>
    <el-table-column
      prop="conInfoTime"
      label="录入日期"
      width="120">
    </el-table-column>
    <el-table-column
      prop="conAudTime"
      label="审核日期"
      width="120">
    </el-table-column>
    <el-table-column
      prop="ownerName"
      label="业主"
      width="120">
    </el-table-column>
    <el-table-column
      prop="status"
      label="状态"
      width="120">
      <template slot-scope="scope">
        {{scope.row.status==1?"草稿":scope.row.status==2?"已提交":scope.row.status==3?"已解约":scope.row.status==4?"已结束":scope.row.status==9?"作废":""}}
      </template>
    </el-table-column>
    <el-table-column
      prop="createUserid"
      label="操作人id"
      width="120">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button type="text" size="small">导入还款计划</el-button>
        <el-button @click="start(scope.row.id)" type="text" size="small">审核</el-button>
      </template>
    </el-table-column>
  </el-table>

<!--    分页-->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNum"
      :page-sizes="[10, 20, 30]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>

</div>
</template>

<script>
import * as sf from '@/api/harvest/sf.js';
export default {
  name: "index",
  data(){
    return{
      tableData:[],
      total:0,
      pageSize:7,
      pageNum:1,
      queryForm:{},
      value2:[]
    }
  },
  methods:{
    reset(){
      this.queryForm = {};
      this.value2 = [];
    },
    handleSizeChange(val){
      this.pageSize = val;
      this.list();
    },
    handleCurrentChange(val){
      this.pageNum = val;
      this.list();
    },
    //查询列表
    list(){
      this.queryForm.leaseStartTime = this.value2[0];
      this.queryForm.leaseEndTime = this.value2[1];
      sf.searchSfContract(this.queryForm,this.pageNum,this.pageSize).then(res=>{
        this.total = res.data.total;
        this.tableData = res.data.list;
      })
    },

    start(id){
      sf.start(id).then(res=>{
        this.$message.success("审核开始");
        this.list();
      })
    },

  },
  created() {
    this.list();
  }
}
</script>

<style scoped>
.flex{
  text-align: center;
}
</style>
